# Author: mosra <mosra@centrum.cz>
pkgname=magnum-integration-git
pkgver=2020.06.r145.g012d62b
_imgui_pkgver=1.88
pkgrel=1
pkgdesc="Integration libraries for the Magnum C++11/C++14 graphics engine (Git version)"
arch=('i686' 'x86_64')
url="https://magnum.graphics"
license=('MIT')
depends=('magnum-git' 'bullet' 'eigen' 'glm')
makedepends=('cmake' 'git' 'ninja')
provides=('magnum-integration')
conflicts=('magnum-integration')
source=("git+https://github.com/mosra/magnum-integration.git"
        "https://github.com/ocornut/imgui/archive/v${_imgui_pkgver}.tar.gz")
sha1sums=('SKIP'
          '5fb89f2b4af95ca168c67f16865f08e780a39b56')

pkgver() {
    cd "$srcdir/${pkgname%-git}"
    git describe --long | sed -r 's/([^-]*-g)/r\1/;s/-/./g;s/v//g'
}

build() {
    mkdir -p "$srcdir/build"
    cd "$srcdir/build"

    # Bundle ImGui
    ln -sf $srcdir/imgui-${_imgui_pkgver}/ "$srcdir/${pkgname%-git}/src/MagnumExternal/ImGui"

    cmake "$srcdir/${pkgname%-git}" \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DMAGNUM_WITH_BULLET=ON \
        -DMAGNUM_WITH_EIGEN=ON \
        -DMAGNUM_WITH_GLM=ON \
        -DMAGNUM_WITH_DART=OFF \
        -DMAGNUM_WITH_IMGUI=ON \
        -G Ninja
    ninja
}

package() {
    cd "$srcdir/build"
    DESTDIR="$pkgdir/" ninja install
}
